#include<iostream>
#include<unistd.h>
#include<cstdlib>
#include<string>




bool GetQueryString(std::string& query_string)
{
    bool ret=false;
    std::string method=getenv("METHOD");
    if(method=="GET")
    {
        query_string=getenv("QUERY_STRING");
        ret=true;
        //cerr<<"Debug test: QUERY_STRING: "<<query_string<<endl;
    }else if(method=="POST")
    {
        int content_length=atoi(getenv("CONTENT_LENGTH"));
        //cerr<<"content length: "<<content_length<<endl;
        char c = 0;
        while(content_length--)
        {
            read(0,&c,1);
            query_string.push_back(c);
            ret=true;
        }
        //cerr<<"Debug test: QUERY_STRING: "<< query_string <<endl;
    }else
    {}
    return ret;
}
void CutString(std::string& in,const std::string& sep,std::string&out1,std::string&out2)
{
    auto pos=in.find(sep);
    if(pos!=std::string::npos)
    {
        out1=in.substr(0,pos);
        out2=in.substr(pos+sep.size());
    }else
    {

    }
}
